package com.gxwzxy.medic.service.Impl;

import java.util.List;

import com.gxwzxy.medic.dao.MedicalDao;
import com.gxwzxy.medic.dao.Impl.MedicalDaoImpl;
import com.gxwzxy.medic.entity.Medical;
import com.gxwzxy.medic.entity.otherentity.S201;
import com.gxwzxy.medic.service.MedicalService;
import com.gxwzxy.medic.until.PageBean;

public class MedicalServiceImpl implements MedicalService {

	/**
	 * 分页
	 */
	@Override
	public void pageMedical(PageBean<Medical> pu) {
		MedicalDao md = new MedicalDaoImpl();
		//查询数据库表获取记录总数
		int totalCount = md.findMedicalSize();
		//使用记录总数计算PageBean中其他属性：totalPageCount(总页数)，numbers(页数集合)
		pu.setTotalCount(totalCount);
		//调用Dao层获取指定页数的学生数据，并放入PageBean的list属性
		int start = pu.getStartRow();
		int size = pu.getSize();
		List<Medical> lu = md.findMedicalIndex(start,size);
		pu.setList(lu);
	}

	/**
	 * 查询S201关系表
	 */
	@Override
	public List<S201> findS201() {
		MedicalDao md = new MedicalDaoImpl();
		return md.findS201();
	}

	/**
	 * 保存医疗机构
	 */
	@Override
	public boolean saveMedical(Medical m) {
		MedicalDao md = new MedicalDaoImpl();
		return md.saveMedical(m);
	}

	/**
	 * 根据medicalcode查询医疗机构
	 */
	@Override
	public List<Medical> findMedicalByMcode(String medicalcode) {
		MedicalDao md = new MedicalDaoImpl();
		return md.findMedicalByMcode(medicalcode);
	}

	/**
	 * 根据medicalcode修改医疗机构
	 */
	@Override
	public boolean updateMedical(Medical m) {
		MedicalDao md = new MedicalDaoImpl();
		return md.updateMedical(m);
	}

	/**
	 * 根据medicalcode删除医疗机构
	 */
	@Override
	public boolean deleteMedical(String medicalcode) {
		MedicalDao md = new MedicalDaoImpl();
		return md.deleteMedical(medicalcode);
	}

}
